" -----------------------------------------------------------------------------
"  "  < 判断操作系统是否是 Windows 还是 Linux >
"  "
"  -----------------------------------------------------------------------------
let g:iswindows = 0
let g:islinux = 0
if(has("win32") || has("win64") || has("win95") || has("win16"))
    let g:iswindows = 1
    source $VIM/vimrc                             " 加载gvim特殊的配置
else
    let g:islinux = 1
endif


" -----------------------------------------------------------------------------
" 编码配置 
" -----------------------------------------------------------------------------
set encoding=utf-8
set fileencodings=utf-8,utf8-bom,gbk,gb2312,latin-1
if version >= 603
    set helplang=cn                               " 使用中文帮助
endif

" -----------------------------------------------------------------------------
" 通用配置 
" -----------------------------------------------------------------------------
set nocompatible           " be iMproved

set history=1024           " Number of things to remember in history
set timeoutlen=250         " Time to wait after ESC (default causes an annoying delay)
set clipboard+=unnamed     " Yanks go on clipboard instead
set shiftround             " round indent to multiple of 'shiftwidth'

" set modeline
" set modelines=5            " default numbers of lines to read for modeline instructions.

set autowrite               " Writes on make/shell commads
set autoread                " 自动重新加载外部修改内容
set autochdir               " 自动切换当前目录为当前文件所在的目录

" 默认无备份
set nobackup
set nowritebackup
set noswapfile

let mapleader = "-"

set nowrap                  " 设置不自动换行
set textwidth=0            " Don't wrap lines by default

" 在insert模式下能用删除键进行删除
set backspace=indent,eol,start

" -----------------------------------------------------------------------------
" 显示配置 
" -----------------------------------------------------------------------------
filetype on                            " 启用文件类型侦测
filetype plugin on                     " 针对不同的文件类型加载对应的插件
filetype plugin indent on              " 启用缩进

if has("syntax")
    syntax on              " enable syntax
endif
" set t_Co=256               " 在终端启用256色

set mouse-=a               " 不使用鼠标
set number                 " 显示行号
set showmatch              " 显示括号配对

" 搜索
set hlsearch               " 高亮搜索
set incsearch              " 在输入要搜索的文字时，实时匹配
set ignorecase             " 搜索模式里忽略大小写
set smartcase              " 如果搜索模式包含大写字符，不使用 'ignorecase' 选项

set tabstop=4              " 设置Tab键的宽度，可以更改，如：宽度为2
set softtabstop=4
set shiftwidth=4           " default shift width for indents
set expandtab              " 将Tab键转换为空格
set smarttab               " 指定按一次backspace就删除shiftwidth宽度


set novisualbell           " 不要闪烁
set noerrorbells           " no noise
set vb t_vb=               " disable any beeps or flashes on error

" 缩进
set autoindent
set cindent                " 启用智能对齐方式
set indentkeys-=0#         " do not break indent on #
set cinkeys-=0#
set cinoptions=:s,ps,ts,cs
set cinwords=if,else,while,do
set cinwords+=for,switch,case

" set shortmess=atI          " shortes messages
set showcmd                " display an incomplete comand in statusline

" 显示状态行当前设置
set statusline=

" 设置状态行显示常用信息
" %n 显示当前buffer索引
" %f 仅显示当前buffer文件的文件名
" %F 显示当前buffer文件的完整路径
" %m 当前缓冲被修改标记,[+], 如果'modifiable=off'是[-]
" %M 当前缓冲被修改标记,+ 或 -
" %r 当前缓冲只读标记,[RO]
" %h 帮助缓冲标记
" %w 预览缓冲标记,[Preview]
" %W 预览缓冲标记,[PRV]
" %Y 文件类型
" %b ASCII值
" %B 十六进制值
" %l 行数
" %v 列数
" %p 当前行数占总行数的的百分比
" %L 总行数
" %{...} 评估表达式的值，并用值代替
" %{"[fenc=".(&fenc==""?&enc:&fenc).((exists("+bomb") && &bomb)?"+":"")."]"} 显示文件编码
" %{&ff} 显示文件类型
set statusline=[%n]\ %f%m%r%h%w%=\ [ft=%Y]\ %{\"[fenc=\".(&fenc==\"\"?&enc:&fenc).((exists(\"+bomb\")\ &&\ &bomb)?\"+\":\"\").\"]\"}\ [ff=%{&ff}]\ [pos=%04l,%04v][%p%%]\ [len=%L]

" 设置 laststatus = 0 ，不显式状态行
" 设置 laststatus = 1 ，仅当窗口多于一个时，显示状态行
" 设置 laststatus = 2 ，总是显式状态行
set laststatus=2

" Convenient command to see the difference between the current buffer and the
" " file it was loaded from, thus the changes you made.
" " Only define it when not defined already.
if !exists(":DiffOrig")
    command DiffOrig vert new | set bt=nofile | r ++edit # | 0d_ | diffthis
                \ | wincmd p | diffthis
endif

